package com.shui_shui;

import com.shui_shui.detailview.DetailView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;

public class GuideActivity extends Activity implements OnTouchListener {
	
	private DetailView detailView;
	private Intent newActivity;
	private ImageView back;	
	private ImageView help; 
	private Button mb1;
	private Button mb2;
	private Button mb3;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guideview);
		
		// Menu Image
		back = (ImageView) findViewById(R.id.back);
		help = (ImageView) findViewById(R.id.help);
		
		mb1 = (Button) findViewById(R.id.guide_button1);
		mb2 = (Button) findViewById(R.id.guide_button2);
		mb3 = (Button) findViewById(R.id.guide_button3);

		// Set Even OnTouch MenuBar
		back.setOnTouchListener(this);
		help.setOnTouchListener(this);
		
		detailView = DetailView.getView();
		
		mb1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				int id = 1;
				detailView.setIdView(id);
				newActivity = new Intent(GuideActivity.this, Guide.class);
				startActivity(newActivity);
			}
		});
		
		mb2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				int id = 2;
				detailView.setIdView(id);
				newActivity = new Intent(GuideActivity.this, Guide.class);
				startActivity(newActivity);
			}
		});
		
		mb3.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				int id = 3;
				detailView.setIdView(id);
				newActivity = new Intent(GuideActivity.this, Guide.class);
				startActivity(newActivity);
			}
		});
	}
	
	
	@SuppressWarnings("deprecation")
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		switch (v.getId()) {              
		case R.id.back:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				back.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				back.setAlpha(255);	
				this.finish();
				break;            
			default:                
				break;            
			}            
			break;        
		case R.id.help:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				help.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				help.setAlpha(255);                
				break;            
			default:                
				break;            
			}            
			break; 
		}        
		return true;
	}
	
}
